import {createApp} from 'vue'
import router, {setupRouter} from '@/router'
import {setupStore} from '@/store'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'element-plus/dist/index.css'
import "@/assets/var.scss";
import '@/assets/layout.scss'
import App from './App.vue'
import {initFunction} from "@/plugins";
import '@/browser_patch.js'
import "@/assets/format.scss";
import "@/assets/animation.scss";

// const app = createApp(App)


// app.use(ElementPlus)
// app.mount('#app')


async function appInit() {

    const app = createApp(App)


    // // 注册全局自定义组件
    // setupCustomComponents(app)

    // // 挂载状态管理
    setupStore(app)

    // 挂载路由
    setupRouter(app)

    // 路由准备就绪后挂载APP实例
    await router.isReady()

    //全局注册Element Icon
    // 必须写在 mount之前
    for (const iconName in ElementPlusIconsVue) {
        app.component(iconName, ElementPlusIconsVue[iconName])
    }

    app.use(ElementPlus, {
        locale: zhCn
    })


    // 挂载到页面
    app.mount('#app', true)

    // 挂载到 window
    window['$vue'] = app
}

appInit().then(() => {
    initFunction()
})


